package com.foreknow.practice.demo166;

import com.foreknow.demo16.User;


import java.util.*;

public class ExamCollection {
    public static void main(String[] args) {
        List<Map<String, User>> list = new ArrayList();
        Map<String ,User> map1= new HashMap<>();
        User u1 = new User();
        u1.setName("tom");
        User u2 = new User();
        u2.setName("fender");
        //将对象保存
        map1.put("1",u1);
        map1.put("2",u2);
        Map<String ,User> map2= new HashMap<>();
        User u3 = new User();
        u3.setName("111");
        User u4 = new User();
        u4.setName("222");
        map2.put("3",u3);
        map2.put("4",u4);
        Map<String ,User> map3= new HashMap<>();
        User u5 = new User();
        u5.setName("333");
        User u6 = new User();
        u6.setName("444");
        map3.put("5",u5);
        map3.put("6",u6);
        list.add(map1);
        list.add(map2);
        list.add(map3);

        //遍历
        for (int i=0;i<list.size();i++){
            Map<String,User>map= list.get(i);
            Set<Map.Entry<String ,User>>set= map.entrySet();
           Iterator<Map.Entry<String,User>>it = set.iterator();
           while (it.hasNext()){
               Map.Entry<String,User> m=it.next();
              String key= m.getKey();
               User value =m.getValue();
               System.out.println(key+value);
           }
        }

    }
}
